﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;


namespace NHibernateTest
{
    public class Employee
    {
        private int empId;
        private string empName; 
        private string email ;
        private double salary ;

        private Dept dept;

        public virtual int EmpId
        {
            get { return empId; }
            set { empId = value; }
        }

        public virtual string EmpName
        {
            get { return empName; }
            set { empName = value; }
        }

        public virtual string Email
        {
            get { return email; }
            set { email = value; }
        }

        public virtual double Salary
        {
            get { return salary; }
            set { salary = value; }
        }

        public virtual Dept Dept1
        {
            get { return dept; }
            set { dept = value; }
        }
    }

    public class EmployeeMapClass : ClassMap<Employee>
    {
        public EmployeeMapClass()
        {
            Table("test_employee");
            Id(employee => employee.EmpId).Column("employee_id");
            Map(employee => employee.EmpName,"employee_name").Not.Nullable().Length(50);
            Map(employee => employee.Email, "email_id").Length(50);
            Map(employee => employee.Salary, "salary");

            References<Dept>(employee => employee.Dept1).Column("dept_no").Cascade.All();
        }
    }
}
